package com.vision.admin.cl;

import net.customware.gwt.dispatch.client.DefaultExceptionHandler;
import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.dispatch.client.standard.StandardDispatchAsync;

import com.google.gwt.core.client.GWT;
import com.vision.core.cl.Services;
import com.vision.core.cm.serv.rpc.CompanyGroupService;
import com.vision.core.cm.serv.rpc.CompanyGroupServiceAsync;
import com.vision.core.cm.serv.rpc.CompanyService;
import com.vision.core.cm.serv.rpc.CompanyServiceAsync;
import com.vision.core.cm.serv.rpc.PermissionService;
import com.vision.core.cm.serv.rpc.PermissionServiceAsync;
import com.vision.core.cm.serv.rpc.RoleService;
import com.vision.core.cm.serv.rpc.RoleServiceAsync;
import com.vision.core.cm.serv.rpc.UserService;
import com.vision.core.cm.serv.rpc.UserServiceAsync;

/**
 * 
 * @author Mark
 *
 */
public class AdminServices {
	
	private static CompanyServiceAsync companySvc;
	private static CompanyGroupServiceAsync companyGroupSvc;
	private static UserServiceAsync userSvc;
	private static RoleServiceAsync roleSvc;
	private static PermissionServiceAsync permissionSvc;
	
	private static DispatchAsync dispatchSvc;
	
	public static CompanyServiceAsync companySvc() {
		if (companySvc == null)
			companySvc = Services.create(GWT.create(CompanyService.class));
		return companySvc;
	}
	
	public static CompanyGroupServiceAsync companyGroupSvc() {
		if (companyGroupSvc == null)
			companyGroupSvc = Services.create(GWT.create(CompanyGroupService.class));
		return companyGroupSvc;
	}
	
	public static UserServiceAsync userSvc() {
		if (userSvc == null)
			userSvc = Services.create(GWT.create(UserService.class));
		return userSvc;
	}
	
	public static RoleServiceAsync roleSvc() {
		if (roleSvc == null)
			roleSvc = Services.create(GWT.create(RoleService.class));
		return roleSvc;
	}
	
	public static PermissionServiceAsync permissionSvc() {
		if (permissionSvc == null)
			permissionSvc = Services.create(GWT.create(PermissionService.class));
		return permissionSvc;
	}
	
	public static DispatchAsync dispatchSvc() {
		if (dispatchSvc == null)
			dispatchSvc = new StandardDispatchAsync(new DefaultExceptionHandler());
		return dispatchSvc;
	}

}
